Imports System.IO
Imports System.Data.SqlClient
Imports System
Imports System.Text
Imports System.Data.Odbc
Public Class FrmHistology
    Public GV_ISEDIT As Boolean = False
    Private Sub Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint

    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Close()

    End Sub

    Private Sub ClearText()
        txtTumourSize.Text = ""
        cbxExtChestWall.SelectedIndex = -1
        cbxClinAxillaryLN.SelectedIndex = -1

        cbxTypeBiopsy.SelectedIndex = -1
        dtDateBiopsy.Value = "01/01/1900"
        cbxHistoDx.SelectedIndex = -1
        DtPrisurg.Value = "01/01/1900"
        cbxTypeSurg.SelectedIndex = -1
        cbxReconstruction.SelectedIndex = -1

        cboxNeoadjuvant.Checked = False
        cboxLocalRec.Checked = False
        cboxSystemic.Checked = False

        txtPhysicalNotes.Text = ""
        txtHistoNotes.Text = ""

        txtHisto_TumourSize.Text = ""
        cbxHistoType.SelectedIndex = -1
        cbxHistoGrade.SelectedIndex = -1
        cbxDCIS.SelectedIndex = -1
        cbxLymhovascular.SelectedIndex = -1
        cbxMargin_invasive.SelectedIndex = -1
        cboxMarginDCIS.SelectedIndex = -1
        cbxradialMargin.SelectedIndex = -1
        txtRadialMargin.Text = ""
        txtDeepMargin.Text = ""
        cbxSentinel_LN.SelectedIndex = -1
        cbxSentinel_LN_result.SelectedIndex = -1
        txtTotal_Ax_LN_Postive.Text = ""
        txtTotal_Ax_LN_Found.Text = ""
        cbxER_Status.SelectedIndex = -1
        cbxPR_Status.SelectedIndex = -1
        cbxErbB2.SelectedIndex = -1

        cbxcT_Status.Text = ""
        cbxN_Status.Text = ""
        cbxM_Status.Text = ""

    End Sub
    Private Sub LoadTypeSurg()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  124", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxTypeSurg.DataSource = list
            Me.cbxTypeSurg.DisplayMember = "Code_desc"
            Me.cbxTypeSurg.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadReconstruction()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  544", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxReconstruction.DataSource = list
            Me.cbxReconstruction.DisplayMember = "Code_desc"
            Me.cbxReconstruction.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadHistoDx()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  118", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("code_desc")), "", objReader("code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxHistoDx.DataSource = list
            Me.cbxHistoDx.DisplayMember = "code_desc"
            Me.cbxHistoDx.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadTypeBiopsy()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  112", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("code_desc")), "", objReader("code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxTypeBiopsy.DataSource = list
            Me.cbxTypeBiopsy.DisplayMember = "code_desc"
            Me.cbxTypeBiopsy.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadClinAxillaryLN()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  107", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("code_desc")), "", objReader("code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxClinAxillaryLN.DataSource = list
            Me.cbxClinAxillaryLN.DisplayMember = "code_desc"
            Me.cbxClinAxillaryLN.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadExtChestWall()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  103", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_Desc", GetType(String)))
            list.Columns.Add(New DataColumn("code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_Desc")), "", objReader("Code_Desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("code")), "", objReader("code"))
                i = i + 1
            Loop
            Me.cbxExtChestWall.DataSource = list
            Me.cbxExtChestWall.DisplayMember = "Code_Desc"
            Me.cbxExtChestWall.ValueMember = "code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
        GV_ISEDIT = False

        Panel2.Enabled = True
        btnEdit.Visible = False
        btnDel.Visible = False
        BtnAdd.Visible = False
        btnSave.Visible = True
        btnCancel.Visible = True
        ClearText()
    End Sub

    Private Sub FrmHistology_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Panel2.Enabled = False
        dtDateBiopsy.Value = "01/01/1900"
        DtPrisurg.Value = "01/01/1900"
        LoadExtChestWall()
        LoadClinAxillaryLN()
        LoadTypeBiopsy()
        LoadHistoDx()
        LoadTypeSurg()
        LoadReconstruction()
        LoadHistoType()
        LoadHistoGrade()
        LoadDCIS()
        LoadLymhovascular()
        LoadMargin_invasive()
        LoadMarginDCIS()
        LoadRadialMargin()
        LoadSentinel_LN()
        LoadSentinel_LN_result()
        LoadER_Status()
        LoadPR_Status()
        LoadErbB2()
        LoadN_Status()
        LoadM_Status()
        LoadcT_Status()

        If GV_SELECTED_HISTOLOGYID <> "" Then
            ListHistology(GV_SELECTED_HISTOLOGYID)
            If GV_FRMEVENT_ALLOW_EDIT = True Then btnEdit_Click(sender, e)
        End If

        Panel1.Enabled = GV_FRMEVENT_ALLOW_EDIT

        If Approved() = True Then
            'btnAdd.Enabled = False
            'btnEdit.Enabled = False
            'btnDel.Enabled = False
            'Panel1.Enabled = False
            'Panel2.Enabled = False
            btnEdit.Enabled = False
            btnSave.Enabled = False
            BtnLock.Text = "Unlock"
            btnDel.Enabled = False
        End If

    End Sub
    Function Approved() As Boolean
        Dim vStatus As String = ""
        Dim vLockBy As String = ""
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("select * from Histology where Histo_ID = '" & GV_SELECTED_HISTOLOGYID & "'", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Do While objReader.Read
                vStatus = IIf(IsDBNull(objReader("Status")), "", objReader("Status"))
                vLockBy = IIf(IsDBNull(objReader("LockedBy")), "", objReader("LockedBy"))
            Loop

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
        If vLockBy <> "" Then
            Approved = True
        Else
            Approved = False
        End If
    End Function
    Private Sub LoadM_Status()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value 207", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxM_Status.DataSource = list
            Me.cbxM_Status.DisplayMember = "Code_desc"
            Me.cbxM_Status.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadN_Status()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value 200", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxN_Status.DataSource = list
            Me.cbxN_Status.DisplayMember = "Code_desc"
            Me.cbxN_Status.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadErbB2()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value 183", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxErbB2.DataSource = list
            Me.cbxErbB2.DisplayMember = "Code_desc"
            Me.cbxErbB2.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadPR_Status()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value 178", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxPR_Status.DataSource = list
            Me.cbxPR_Status.DisplayMember = "Code_desc"
            Me.cbxPR_Status.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadER_Status()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value 173", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxER_Status.DataSource = list
            Me.cbxER_Status.DisplayMember = "Code_desc"
            Me.cbxER_Status.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadSentinel_LN()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  547", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxSentinel_LN.DataSource = list
            Me.cbxSentinel_LN.DisplayMember = "Code_desc"
            Me.cbxSentinel_LN.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub


    Private Sub LoadSentinel_LN_result()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  178", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxSentinel_LN_result.DataSource = list
            Me.cbxSentinel_LN_result.DisplayMember = "Code_desc"
            Me.cbxSentinel_LN_result.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub



    Private Sub LoadRadialMargin()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  165", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxradialMargin.DataSource = list
            Me.cbxradialMargin.DisplayMember = "Code_desc"
            Me.cbxradialMargin.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadMarginDCIS()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  162", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cboxMarginDCIS.DataSource = list
            Me.cboxMarginDCIS.DisplayMember = "Code_desc"
            Me.cboxMarginDCIS.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadMargin_invasive()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  159", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxMargin_invasive.DataSource = list
            Me.cbxMargin_invasive.DisplayMember = "Code_desc"
            Me.cbxMargin_invasive.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadLymhovascular()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  154", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxLymhovascular.DataSource = list
            Me.cbxLymhovascular.DisplayMember = "Code_desc"
            Me.cbxLymhovascular.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadDCIS()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  260", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_Desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_Desc")), "", objReader("Code_Desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxDCIS.DataSource = list
            Me.cbxDCIS.DisplayMember = "Code_Desc"
            Me.cbxDCIS.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadcT_Status()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value 274", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxcT_Status.DataSource = list
            Me.cbxcT_Status.DisplayMember = "Code_desc"
            Me.cbxcT_Status.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub LoadHistoGrade()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  149", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("Code_desc")), "", objReader("Code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxHistoGrade.DataSource = list
            Me.cbxHistoGrade.DisplayMember = "Code_desc"
            Me.cbxHistoGrade.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub

    Private Sub LoadHistoType()
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("exec spGetlookup_Value  132", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Dim i As Integer
            i = 1
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("code_desc", GetType(String)))
            list.Columns.Add(New DataColumn("Code", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = ""
            list.Rows(0)(1) = ""
            Do While objReader.Read
                list.Rows.Add(list.NewRow())
                list.Rows(i)(0) = IIf(IsDBNull(objReader("code_desc")), "", objReader("code_desc"))
                list.Rows(i)(1) = IIf(IsDBNull(objReader("Code")), "", objReader("Code"))
                i = i + 1
            Loop
            Me.cbxHistoType.DataSource = list
            Me.cbxHistoType.DisplayMember = "code_desc"
            Me.cbxHistoType.ValueMember = "Code"

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub
    Private Sub ListHistology(ByVal vHistoID)
        Dim SqlConnection1 As New SqlConnection()
        SqlConnection1 = New SqlConnection(GV_CONNETION)
        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        Dim sqlCmd = New SqlCommand("select * from Histology where Histo_id = '" & vHistoID & "'", SqlConnection1)
        Try
            Dim objReader As SqlDataReader = sqlCmd.ExecuteReader
            Do While objReader.Read
                txtTumourSize.Text = IIf(IsDBNull(objReader("clin_tum_size")), "", objReader("clin_tum_size"))
                cbxExtChestWall.Text = IIf(IsDBNull(objReader("Ext_cw")), "", objReader("Ext_cw"))
                cbxClinAxillaryLN.Text = IIf(IsDBNull(objReader("clin_ax_ln")), "", objReader("clin_ax_ln"))
                cbxTypeBiopsy.Text = IIf(IsDBNull(objReader("biopsy_Type")), "", objReader("biopsy_Type"))
                dtDateBiopsy.Value = IIf(IsDBNull(objReader("date_biopsy")), "01/01/1900", objReader("date_biopsy"))
                cbxHistoDx.Text = IIf(IsDBNull(objReader("histo_Dx")), "", objReader("histo_Dx"))
                DtPrisurg.Value = IIf(IsDBNull(objReader("date_pri_surg")), "01/01/1900", objReader("date_pri_surg"))
                cbxTypeSurg.Text = IIf(IsDBNull(objReader("surg_type")), "", objReader("surg_type"))
                cbxReconstruction.Text = IIf(IsDBNull(objReader("reconstruction")), "", objReader("reconstruction"))
                cboxNeoadjuvant.Checked = IIf(IsDBNull(objReader("chk_Neoadj")), False, objReader("chk_Neoadj"))
                cboxLocalRec.Checked = IIf(IsDBNull(objReader("chk_Local")), False, objReader("chk_Local"))
                cboxSystemic.Checked = IIf(IsDBNull(objReader("chk_Systemic")), False, objReader("chk_Systemic"))
                txtPhysicalNotes.Text = IIf(IsDBNull(objReader("add_physurg_notes")), "", objReader("add_physurg_notes"))
                txtHistoNotes.Text = IIf(IsDBNull(objReader("other_histo_notes")), "", objReader("other_histo_notes"))
                txtHisto_TumourSize.Text = IIf(IsDBNull(objReader("histo_tum_size")), "", objReader("histo_tum_size"))
                cbxHistoType.Text = IIf(IsDBNull(objReader("histo_type")), "", objReader("histo_type"))
                cbxHistoGrade.Text = IIf(IsDBNull(objReader("histo_grade")), "", objReader("histo_grade"))
                cbxDCIS.Text = IIf(IsDBNull(objReader("ass_dcis")), "", objReader("ass_dcis"))
                cbxLymhovascular.Text = IIf(IsDBNull(objReader("lymphovas_inv")), "", objReader("lymphovas_inv"))
                cbxMargin_invasive.Text = IIf(IsDBNull(objReader("marg_inv_ca")), "", objReader("marg_inv_ca"))
                cboxMarginDCIS.Text = IIf(IsDBNull(objReader("marg_dcis")), "", objReader("marg_dcis"))
                cbxradialMargin.Text = IIf(IsDBNull(objReader("closest_marg")), "", objReader("closest_marg"))
                txtRadialMargin.Text = IIf(IsDBNull(objReader("closest_marg_size")), "", objReader("closest_marg_size"))
                txtDeepMargin.Text = IIf(IsDBNull(objReader("deep_marg_size")), "", objReader("deep_marg_size"))
                cbxSentinel_LN.Text = IIf(IsDBNull(objReader("SLN_1")), "", objReader("SLN_1"))
                txtTotal_Ax_LN_Postive.Text = IIf(IsDBNull(objReader("ax_ln_pos")), "", objReader("ax_ln_pos"))
                txtTotal_Ax_LN_Found.Text = IIf(IsDBNull(objReader("ax_ln_fd")), "", objReader("ax_ln_fd"))
                cbxER_Status.Text = IIf(IsDBNull(objReader("er_status")), "", objReader("er_status"))
                cbxPR_Status.Text = IIf(IsDBNull(objReader("pr_status")), "", objReader("pr_status"))
                cbxErbB2.Text = IIf(IsDBNull(objReader("c_erbb2_status")), "", objReader("c_erbb2_status"))
                cbxcT_Status.Text = IIf(IsDBNull(objReader("t_stage_6")), "", objReader("t_stage_6"))
                cbxN_Status.Text = IIf(IsDBNull(objReader("n_stage_6")), "", objReader("n_stage_6"))
                cbxM_Status.Text = IIf(IsDBNull(objReader("m_stage_6")), "", objReader("m_stage_6"))
                Lbl_EnBy.Text = "Entered By:" & vbCrLf & IIf(IsDBNull(objReader("EnteredBy")), "", objReader("EnteredBy"))
                Lbl_UpdBy.Text = "Updated By:" & vbCrLf & IIf(IsDBNull(objReader("UpdatedBy")), "", objReader("UpdatedBy"))
                Lbl_LockBy.Text = "Locked By:" & vbCrLf & IIf(IsDBNull(objReader("LockedBy")), "", objReader("LockedBy"))

            Loop

        Catch e As Exception
            MsgBox(e.Source)
        End Try

        sqlCmd.Cancel()
        SqlConnection1.Close()
        sqlCmd = Nothing
        SqlConnection1.Close()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        If GV_ISEDIT = False Then ClearText() Else ListHistology(GV_SELECTED_HISTOLOGYID)
        Panel2.Enabled = False
        BtnAdd.Visible = True
        btnEdit.Visible = True
        btnDel.Visible = True
        btnSave.Visible = False
        btnCancel.Visible = False
    End Sub

    Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
        If GV_SELECTED_HISTOLOGYID <> "" Then
            Dim response As Integer

            response = MsgBox("Are you sure want to delete this record?", MsgBoxStyle.YesNo, "Delete")
            If response = 7 Then
                Exit Sub
            End If

            Dim myCommand As SqlCommand
            Dim SqlConn As New SqlConnection()
            SqlConn = New SqlConnection(GV_CONNETION)
            myCommand = New SqlCommand("spDelHistology", SqlConn)
            myCommand.CommandType = CommandType.StoredProcedure
            SqlConn.Open()

            myCommand.Parameters.Add("@Histo_ID", SqlDbType.VarChar)
            myCommand.Parameters.Add("@EnteredBy", SqlDbType.VarChar)
            myCommand.Parameters("@Histo_ID").Value = GV_SELECTED_HISTOLOGYID
            myCommand.Parameters("@EnteredBy").Value = GV_USER

            myCommand.ExecuteNonQuery()

            myCommand.Cancel()
            SqlConn.Close()
            myCommand = Nothing
            SqlConn = Nothing
            Close()
            FrmDiagnosis.Close()
            FrmDiagnosis.Show()
        End If
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        If GV_SELECTED_HISTOLOGYID <> "" Then
            GV_ISEDIT = True
            Panel2.Enabled = True
            btnEdit.Visible = False
            btnDel.Visible = False
            BtnAdd.Visible = False
            btnSave.Visible = True
            btnCancel.Visible = True
        End If
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        SaveHistology()
        Panel2.Enabled = False
        Close()
        If GV_SELECTED_DATAENTRY_MODE = "PRESENTATION" Then
            FrmPresentDataEntry.Close()
            FrmPresentDataEntry.Show()
            FrmPresentDataEntry.Focus()

        Else
            FrmDiagnosis.Close()
            FrmDiagnosis.Show()
            FrmDiagnosis.Focus()
        End If
    End Sub

    Private Sub SaveHistology()
        Dim myCommand As SqlCommand
        Dim SqlConn As New SqlConnection()
        SqlConn = New SqlConnection(GV_CONNETION)
        myCommand = New SqlCommand("spInsertHistology", SqlConn)
        myCommand.CommandType = CommandType.StoredProcedure
        SqlConn.Open()

        myCommand.Parameters.Add("@Histo_ID", SqlDbType.VarChar)
        myCommand.Parameters.Add("@Event_ID", SqlDbType.VarChar)
        myCommand.Parameters.Add("@Pt_id1", SqlDbType.VarChar)
        myCommand.Parameters.Add("@clin_tum_size", SqlDbType.VarChar)
        myCommand.Parameters.Add("@Ext_cw", SqlDbType.VarChar)
        myCommand.Parameters.Add("@clin_ax_ln", SqlDbType.VarChar)
        myCommand.Parameters.Add("@biopsy_Type", SqlDbType.VarChar)
        myCommand.Parameters.Add("@date_biopsy", SqlDbType.DateTime)
        myCommand.Parameters.Add("@histo_Dx", SqlDbType.VarChar)
        myCommand.Parameters.Add("@date_pri_surg", SqlDbType.DateTime)
        myCommand.Parameters.Add("@surg_type", SqlDbType.VarChar)
        myCommand.Parameters.Add("@reconstruction", SqlDbType.VarChar)
        myCommand.Parameters.Add("@chk_Neoadj", SqlDbType.Bit)
        myCommand.Parameters.Add("@chk_Local", SqlDbType.Bit)
        myCommand.Parameters.Add("@chk_Systemic", SqlDbType.Bit)
        myCommand.Parameters.Add("@add_physurg_notes", SqlDbType.VarChar)
        myCommand.Parameters.Add("@other_histo_notes", SqlDbType.VarChar)
        myCommand.Parameters.Add("@histo_tum_size", SqlDbType.VarChar)
        myCommand.Parameters.Add("@histo_type", SqlDbType.VarChar)
        myCommand.Parameters.Add("@histo_grade", SqlDbType.VarChar)
        myCommand.Parameters.Add("@ass_dcis", SqlDbType.VarChar)
        myCommand.Parameters.Add("@lymphovas_inv", SqlDbType.VarChar)
        myCommand.Parameters.Add("@marg_inv_ca", SqlDbType.VarChar)
        myCommand.Parameters.Add("@marg_dcis", SqlDbType.VarChar)
        myCommand.Parameters.Add("@closest_marg", SqlDbType.VarChar)
        myCommand.Parameters.Add("@closest_marg_size", SqlDbType.VarChar)
        myCommand.Parameters.Add("@deep_marg_size", SqlDbType.VarChar)
        myCommand.Parameters.Add("@SLN_1", SqlDbType.VarChar)
        myCommand.Parameters.Add("@SLN_2", SqlDbType.VarChar)
        myCommand.Parameters.Add("@ax_ln_pos", SqlDbType.VarChar)
        myCommand.Parameters.Add("@ax_ln_fd", SqlDbType.VarChar)
        myCommand.Parameters.Add("@er_status", SqlDbType.VarChar)
        myCommand.Parameters.Add("@pr_status", SqlDbType.VarChar)
        myCommand.Parameters.Add("@c_erbb2_status", SqlDbType.VarChar)
        myCommand.Parameters.Add("@t_stage_6", SqlDbType.VarChar)
        myCommand.Parameters.Add("@n_stage_6", SqlDbType.VarChar)
        myCommand.Parameters.Add("@m_stage_6", SqlDbType.VarChar)
        myCommand.Parameters.Add("@EnteredBy", SqlDbType.VarChar)

        If GV_ISEDIT = True Then
            myCommand.Parameters("@Histo_ID").Value = GV_SELECTED_HISTOLOGYID
        Else
            myCommand.Parameters("@Histo_ID").Value = "0"
        End If
        myCommand.Parameters("@Pt_id1").Value = GV_CUR_PATID
        myCommand.Parameters("@Event_ID").Value = GV_SELECTED_EVENTID
        myCommand.Parameters("@clin_tum_size").Value = Trim(txtTumourSize.Text)
        myCommand.Parameters("@Ext_cw").Value = Trim(cbxExtChestWall.Text)
        myCommand.Parameters("@clin_ax_ln").Value = Trim(cbxClinAxillaryLN.Text)
        myCommand.Parameters("@biopsy_Type").Value = Trim(cbxTypeBiopsy.Text)
        myCommand.Parameters("@date_biopsy").Value = dtDateBiopsy.Value
        myCommand.Parameters("@histo_Dx").Value = Trim(cbxHistoDx.Text)
        myCommand.Parameters("@date_pri_surg").Value = DtPrisurg.Value
        myCommand.Parameters("@surg_type").Value = Trim(cbxTypeSurg.Text)
        myCommand.Parameters("@reconstruction").Value = Trim(cbxReconstruction.Text)
        myCommand.Parameters("@chk_Neoadj").Value = cboxNeoadjuvant.Checked
        myCommand.Parameters("@chk_Local").Value = cboxLocalRec.Checked
        myCommand.Parameters("@chk_Systemic").Value = cboxSystemic.Checked
        myCommand.Parameters("@add_physurg_notes").Value = Trim(txtPhysicalNotes.Text)
        myCommand.Parameters("@other_histo_notes").Value = Trim(txtHistoNotes.Text)
        myCommand.Parameters("@histo_tum_size").Value = Trim(txtHisto_TumourSize.Text)
        myCommand.Parameters("@histo_type").Value = Trim(cbxHistoType.Text)
        myCommand.Parameters("@histo_grade").Value = Trim(cbxHistoGrade.Text)
        myCommand.Parameters("@ass_dcis").Value = Trim(cbxDCIS.Text)
        myCommand.Parameters("@lymphovas_inv").Value = Trim(cbxLymhovascular.Text)
        myCommand.Parameters("@marg_inv_ca").Value = Trim(cbxMargin_invasive.Text)
        myCommand.Parameters("@marg_dcis").Value = Trim(cboxMarginDCIS.Text)
        myCommand.Parameters("@closest_marg").Value = Trim(cbxradialMargin.Text)
        myCommand.Parameters("@closest_marg_size").Value = Trim(txtRadialMargin.Text)
        myCommand.Parameters("@deep_marg_size").Value = Trim(txtDeepMargin.Text)
        myCommand.Parameters("@SLN_1").Value = Trim(cbxSentinel_LN.Text)
        myCommand.Parameters("@SLN_2").Value = Trim(cbxSentinel_LN.Text)
        myCommand.Parameters("@ax_ln_pos").Value = Trim(txtTotal_Ax_LN_Postive.Text)
        myCommand.Parameters("@ax_ln_fd").Value = Trim(txtTotal_Ax_LN_Found.Text)
        myCommand.Parameters("@er_status").Value = Trim(cbxER_Status.Text)
        myCommand.Parameters("@pr_status").Value = Trim(cbxPR_Status.Text)
        myCommand.Parameters("@c_erbb2_status").Value = Trim(cbxErbB2.Text)
        myCommand.Parameters("@t_stage_6").Value = Trim(cbxcT_Status.Text)
        myCommand.Parameters("@n_stage_6").Value = Trim(cbxN_Status.Text)
        myCommand.Parameters("@m_stage_6").Value = Trim(cbxM_Status.Text)
        myCommand.Parameters("@EnteredBy").Value = GV_USER

        Try
            myCommand.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox("Please Fill in SLNB inforamtion.")
        End Try

        myCommand.Cancel()
        SqlConn.Close()
        myCommand = Nothing
        SqlConn = Nothing
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        FrmNeoadjuvant.ShowDialog()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        FrmRcdPriorTreatment.ShowDialog()
    End Sub

    Private Sub FrmHistology_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

    End Sub

    Private Sub BtnLock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLock.Click
        If BtnLock.Text = "Lock" Then
            If GV_FRMEVENT_ALLOW_APPROVE = False Then
                MsgBox("Permission denied.", MsgBoxStyle.Information)
                Exit Sub
            End If
        End If

        If BtnLock.Text = "UnLock" Then
            If GV_FRMEVENT_ALLOW_APPROVE = False Then
                MsgBox("Permission denied.", MsgBoxStyle.Information)
                Exit Sub
            End If
        End If

        Dim myCommand As SqlCommand
        Dim SqlConn As New SqlConnection()
        SqlConn = New SqlConnection(GV_CONNETION)
        myCommand = New SqlCommand("sp_LockUnlockHistology", SqlConn)
        myCommand.CommandType = CommandType.StoredProcedure
        SqlConn.Open()
        myCommand.Parameters.Add("@Histo_ID", SqlDbType.VarChar)
        myCommand.Parameters.Add("@EnteredBy", SqlDbType.VarChar)
        myCommand.Parameters.Add("@LockFlag", SqlDbType.VarChar)

        myCommand.Parameters("@Histo_ID").Value = GV_SELECTED_HISTOLOGYID
        myCommand.Parameters("@EnteredBy").Value = GV_USER
        myCommand.Parameters("@LockFlag").Value = Trim(BtnLock.Text)
        myCommand.ExecuteNonQuery()

        myCommand.Cancel()
        SqlConn.Close()
        myCommand = Nothing
        SqlConn = Nothing

        If BtnLock.Text = "Lock" Then
            BtnLock.Text = "UnLock"
            btnEdit.Enabled = False
            btnSave.Enabled = False
            btnDel.Enabled = False
            Lbl_LockBy.Text = "Locked By:" & vbCrLf & GV_USERNAME
        Else
            BtnLock.Text = "Lock"
            btnEdit.Enabled = GV_FRMEVENT_ALLOW_EDIT
            btnSave.Enabled = GV_FRMEVENT_ALLOW_EDIT
            btnDel.Enabled = GV_FRMEVENT_ALLOW_EDIT
            Lbl_LockBy.Text = "Locked By:"
        End If
    End Sub
End Class